﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using Models.Repository;

namespace springProject.Models
{
    public class EditPageContent
    {
       
        public EditPageContent(PageContent page) 
        {
            ContentId = page.ContentId;
            Summary = page.Summary;
            Description = page.Description;
            KeyWords = page.KeyWords;
            EditDate = page.EditDate;
            Content = page.Content;
            FolderId = (Guid) page.FolderId;
        }
        public EditPageContent(){}

        public Guid ContentId { get; set; }
        public string Summary { get; set; }
        public string Description { get; set; }
        public string KeyWords { get; set; }
        public DateTime EditDate { get; set; }
        public string Content { get; set; }
        public Guid FolderId { get; set; }

        public PageContent ConvertToPageContent(Repository repository)
        {
            var result = repository.GetById<PageContent>(ContentId);
            result.ContentId = ContentId;
            result.Summary = Summary;
            result.Description = Description;
            result.KeyWords = KeyWords;
            result.EditDate = EditDate;
            result.Content = Content;
            result.FolderId = FolderId;
            result.Folders = new Folders();
            return result;
        }
    }
}